﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Drawing;

namespace UserDefineForm.control.propertymapping
{
    public class MappingObjectBase
    {
        protected DesignableControlBase control;
        [CategoryAttribute("General")]
        public virtual string Name { set; get; }

        [CategoryAttribute("General")]
        public virtual Font Font { set; get; }

        [CategoryAttribute("Layout")]
        public virtual int Top { set; get; }

        [CategoryAttribute("Layout")]
        public virtual int Left { set; get; }

        [CategoryAttribute("Layout")]
        public virtual int Width { set; get; }

        [BrowsableAttribute(false), CategoryAttribute("Layout")]
        public virtual int Height { set; get; }

        [CategoryAttribute("Value")]
        public virtual string Default { set; get; }

        [BrowsableAttribute(false), CategoryAttribute("Value")]
        public virtual List<String> List { set; get; }

        public void setControl(DesignableControlBase control)
        {
            this.control = control;

            this.Name = control.Name;
            this.Top = control.Top;
            this.Left = control.Left;
            this.Width = control.Width;
            this.Height = control.Height;
            this.Font = control.FontProp;
            this.Default = control.DefaultValue;
            this.List = control.ListValue;
            
        }

        public void applyChanges()
        {
            if (control == null) return;

            control.Name = this.Name;
            control.Top = this.Top;
            control.Left = this.Left;
            control.Width = this.Width;
            control.Height = this.Height;
            control.FontProp = this.Font;
            control.DefaultValue = this.Default;
            control.ListValue = this.List;

            setControl(control);
        }

        public bool checkValidProperties()
        {
            return true;
        }
        
    }
}
